package com.example.demo5.info.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.demo5.info.mapper.LoginMapper;
import com.example.demo5.info.mapper.UserMapper;
import com.example.demo5.info.pojo.Login;
import com.example.demo5.info.service.LoginService;
import com.example.demo5.result.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.UUID;

@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private  LoginMapper loginMapper;
    @Resource
    private LoginService loginService;
    //注册新增
    @PostMapping("/add")
    public AjaxResult insert(@RequestBody Login login){
        return loginService.handleAdd(login);
    };
    //登录
    @GetMapping("/on")
    public AjaxResult loginOn(Login login){
        return loginService.handleOn(login);
    }
    //修改
    @PostMapping("/modify")
    public AjaxResult modify(@RequestBody Login login){
        // 获取id的方法
        return AjaxResult.success(loginMapper.updateById(login));
    }
    //删除
    @DeleteMapping ("/delete/{id}")
    public AjaxResult delete(@PathVariable long id){
        // 获取id的方法
        return AjaxResult.success(loginMapper.deleteById(id));
    }
    //用户详情信息
    @GetMapping("/list/{id}")
    public AjaxResult getIdList(@PathVariable long id){
        return loginService.handeleGetId(id);
    }


   
}
